home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
DB_CLIPP
/
2614.ZIP
/
TBROWS.ZIP
/
TTBR4.PRG
< prev
next >
Wrap
Text File
|
1990-10-22
|
3KB
|
146 lines
/*****
*
* TTBR4.PRG
* Fourth example for TBROWSE class using a database file
*
* 19 October 90
* Luiz Quintela - Nantucket Corp
*
* Clipper ttbr4 /N/W/A/B
* RTLINK FILE ttbr4 PLL base50
*
*/
// Include Header Files
#include "inkey.ch"
#include "setcurs.ch"
FUNCTION Main()
LOCAL b, column, nKey
SET SCOREBOARD OFF
SET DATE BRITISH
SET CONFIRM ON
USE test INDEX test NEW
// Turn cursor off
SETCURSOR(SC_NONE)
SETCOLOR( "BG/B,GR+/B,,,BG/N" ); CLS
b := TBrowseDB( 2, 2, 20, 48)
b:colSep := " │ "
b:headSep := "═╤═"
b:footSep := "═══"
// TBColumn objects
column := TBColumnNew( "Field 1", {|| test->fld1} )
column:footing := "First"
b:addColumn( column )
column := TBColumnNew( "Field 2", {|| test->fld2} )
b:addColumn( column )
column := TBColumnNew( "Field 3", {|| test->fld3} )
b:addColumn( column )
column := TBColumnNew( "Field 4", {|| test->fld4} )
b:addColumn( column )
column := TBColumnNew( "Field 5", {|| test->fld5} )
column:footing := "Last"
b:addColumn( column )
// One useful thing: freeze one or more columns in the screen
// You could accomplish this using the instance variable
// freeze. It defines the number of data columns frozen
// on the feft side of the display
b:freeze := 1
WHILE .T.
// Do not allow cursor to move into frozen columns
// (Optional!)
// You will use the instance variable colPos to get
// current cursor column position
IF ( b:colPos <= 1 )
// As you can see b:colPos is assignable
b:colPos := b:freeze + 1
ENDIF
// Stabilization
WHILE ( !b:stabilize() )
nKey := InKey()
IF ( nKey != 0 )
EXIT // abort if a key is waiting
ENDIF
END
IF ( b:stable )
// Is always a good idea tell the user about end or
// beginning of file
// b:hitTop contais a .T. if an attempt was made
// to navigate beyond the beginning of data source
// b:hitBottom contais a .T. if an attempt was made
// to navigate beyond the end of data source
IF ( b:hitTop .OR. b:hitBottom )
TONE(87.3,1)
TONE(40,3.5)
ENDIF
// everything's done; just wait for a key
nKey := INKEY(0)
ENDIF
// Process key
IF ( nKey == K_DOWN )
b:down()
ELSEIF ( nKey == K_UP )
b:up()
ELSEIF ( nKey == K_PGDN )
b:pageDown()
ELSEIF ( nKey == K_PGUP )
b:pageUp()
ELSEIF ( nKey == K_CTRL_PGUP )
b:goTop()
ELSEIF ( nKey == K_CTRL_PGDN )
b:goBottom()
ELSEIF ( nKey == K_RIGHT )
b:right()
ELSEIF ( nKey == K_LEFT )
b:left()
ELSEIF ( nKey == K_HOME )
b:home()
ELSEIF ( nKey == K_END )
b:end()
ELSEIF ( nKey == K_CTRL_LEFT )
b:panLeft()
ELSEIF ( nKey == K_CTRL_RIGHT )
b:panRight()
ELSEIF ( nKey == K_CTRL_HOME )
b:panHome()
ELSEIF ( nKey == K_CTRL_END )
b:panEnd()
ELSEIF ( nKey == K_ESC )
CLS; SETCURSOR(SC_NORMAL); QUIT
ENDIF
END
/* EOF - TTBR4.PRG */